package com.danger.presenter;

import android.content.Context;

import com.danger.model.action.PlayModel;
import com.danger.model.action.PlayModelImpl;
import com.danger.model.entity.Song;
import com.danger.model.listener.OnScanMusicListener;
import com.danger.view.PlayView;

import java.util.List;

/**
 * Created by 俊 on 2016/8/15.
 */
public class PlayPresenterImpl implements PlayPresenter {

    private PlayModel model;
    private PlayView view;

    public PlayPresenterImpl(Context context, PlayView view) {
        this.view = view;
        model = new PlayModelImpl(context);
    }

    @Override
    public void scanSongs() {
        view.showLoading();
        model.getMusic(new OnScanMusicListener() {
            @Override
            public void onSuccess(List<Song> songs) {
                view.hideLoading();
                view.showSongs(songs);
            }

            @Override
            public void onError(String error) {
                view.hideLoading();
                view.showMessage(error);
            }
        });
    }
}
